// --------------------------------------------------------------------------------------------------------------------
// <copyright file="HeartbeatState.cs" company="Microsoft Corporation">
// The MIT License (MIT)
// 
// Copyright (c) 2014, Microsoft Corporation
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace Microsoft.Robotics.Hardware.DAC
{
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Runtime.Serialization;

    /// <summary>
    /// A read/write implementation of the heartbeat state interface.
    /// </summary>
    [DataContract]
    public class HeartbeatState
    {
        /// <summary>
        /// Initializes a new instance of the HeartbeatState class.
        /// </summary>
        public HeartbeatState()
        {
            this.Timestamp = Stopwatch.GetTimestamp() * 1000 / Stopwatch.Frequency;
            this.Accelerometers = new List<AccelerometerState>();
            this.Batteries = new List<BatteryState>();
            this.Buttons = new List<ButtonState>();
            this.Compasses = new List<CompassState>();
            this.DifferentialDrives = new List<DifferentialDriveState>();
            this.Encoders = new List<EncoderState>();
            this.Fans = new List<FanState>();
            this.Gyroscopes = new List<GyroscopeState>();
            this.HumiditySensors = new List<HumidityState>();
            this.InfraredSensors = new List<IRProximityState>();
            this.Joints = new List<JointState>();
            this.PowerDevices = new List<PowerState>();
            this.Projectors = new List<ProjectorState>();
            this.Sonars = new List<SonarState>();
            this.TemperatureSensors = new List<TemperatureState>();
        }

        /// <summary>
        /// Gets or sets the state Creation time
        /// </summary>
        [DataMember]
        public long Timestamp { get; set; }

        /// <summary>
        /// Gets or sets all accelerometers.
        /// </summary>
        [DataMember]
        public List<AccelerometerState> Accelerometers { get; set; }

        /// <summary>
        /// Gets or sets all batteries.
        /// </summary>
        [DataMember]
        public List<BatteryState> Batteries { get; set; }

        /// <summary>
        /// Gets or sets all buttons.
        /// </summary>
        [DataMember]
        public List<ButtonState> Buttons { get; set; }

        /// <summary>
        /// Gets or sets all compasses.
        /// </summary>
        [DataMember]
        public List<CompassState> Compasses { get; set; }

        /// <summary>
        /// Gets or sets all differential drives.
        /// </summary>
        [DataMember]
        public List<DifferentialDriveState> DifferentialDrives { get; set; }

        /// <summary>
        /// Gets or sets all encoders.
        /// </summary>
        [DataMember]
        public List<EncoderState> Encoders { get; set; }

        /// <summary>
        /// Gets or sets all fans.
        /// </summary>
        [DataMember]
        public List<FanState> Fans { get; set; }

        /// <summary>
        /// Gets or sets all gyroscopes.
        /// </summary>
        [DataMember]
        public List<GyroscopeState> Gyroscopes { get; set; }

        /// <summary>
        /// Gets or sets all humidity sensors.
        /// </summary>
        [DataMember]
        public List<HumidityState> HumiditySensors { get; set; }

        /// <summary>
        /// Gets or sets all infrared sensors.
        /// </summary>
        [DataMember]
        public List<IRProximityState> InfraredSensors { get; set; }

        /// <summary>
        /// Gets or sets all joints.
        /// </summary>
        [DataMember]
        public List<JointState> Joints { get; set; }

        /// <summary>
        /// Gets or sets all power devices.
        /// </summary>
        [DataMember]
        public List<PowerState> PowerDevices { get; set; }

        /// <summary>
        /// Gets or sets all projectors.
        /// </summary>
        [DataMember]
        public List<ProjectorState> Projectors { get; set; }

        /// <summary>
        /// Gets or sets all sonars.
        /// </summary>
        [DataMember]
        public List<SonarState> Sonars { get; set; }

        /// <summary>
        /// Gets or sets all temperature sensors.
        /// </summary>
        [DataMember]
        public List<TemperatureState> TemperatureSensors { get; set; }
    }
}
